The Dreamweaver JavaScript API > Deprecated functions > dreamweaver.offsetsToNode()

 

dreamweaver.offsetsToNode()

Availability

Dreamweaver 2.0, deprecated in 3.0 in favor of dom.offsetsToNode().

Description

Gets the object in the DOM tree that completely contains the range of characters between the specified begin and end points.

Arguments

offsetBegin, offsetEnd

The arguments are the begin and end points, respectively, of a range of characters, expressed as byte offsets into the document's HTML source code.

Returns

The tag, text, or comment object that completely contains the specified range of characters.

Example

The following code displays an alert if the selection is an image:

var offsets = dreamweaver.getSelection();
var theSelection = dreamweaver.offsetsToNode(offsets[0], ¬
offsets[1]);
if (theSelection.nodeType == Node.ELEMENT_NODE && ¬
theSelection.tagName == 'IMG'){
	alert('The current selection is an image.');
}